package project2011;
import java.util.*;
/**
 * A SellerList stores sellers in an ArrayList called sellerList
 * @author Antone Gonzalez
 */
public class SellerList {
    
    /**
     * Constructor for SellerList
     */
    public SellerList()
    {
        sellerList = new ArrayList<Seller>();
    }
    
    /**
     * Takes a string and returns a seller with that name
     * If no Seller exists, function returns null
     * @param name the Seller name to find
     * @return the Seller with the passed in name
     */
    public Seller findSeller(String name)
    {
        for(Seller x: sellerList)
        {
            if(x.getName().equals(name))
            {
                return x;
            }
        }
        
        return null;
    }
    
    /**
     * Prints the details of all Sellers in sellerList
     * as well as any products they have in their respective inventories
     * @return a String containing details of Sellers and their inventories
     */
    public String print()
    {
        String result = new String();
        for(Seller x: sellerList)
        {
            result += x.print();
            result += x.printInventory();
        }
        return result;
    }
    
    /**
     * Adds a passed in Seller to sellerList
     * @param toAdd the Seller to be added to sellerList
     */
    public void addSeller(Seller toAdd)
    {
        sellerList.add(toAdd);
    }
    
    private ArrayList<Seller> sellerList;
}
